#include <cstdio>
#include <cmath>
#include <cstring>

int n, m, l, next[ 11 ];
double f[ 1001 ][ 11 ], p[ 26 ], sum;
char a[ 11 ];

void getnext( char *s, int *next )
{
    int i = 1, j = -1;
    next[ 0 ] = -1;
    while ( s[ i ] )
    {
        while ( j >= 0 && s[ j + 1 ] != s[ i ] ) j = next[ j ];
        if ( s[ j + 1 ] == s[ i ] ) j++;
        next[ i++ ] = j;
    }
}

void init( )
{
    int i;
    char t[ 2 ];
    sum = 0;
    memset( p, 0, sizeof( p ) );
    for ( i = 0; i < n; i++ )
    {
        scanf("%s", t);
        scanf("%lf", &p[ t[ 0 ] - 'a' ]);
    }
    scanf("%s", a);
    getnext( a, next );
    l = strlen( a );
    memset( f, 0, sizeof( f ) );
    f[ 0 ][ 1 ] = p[ a[ 0 ] - 'a' ];
    f[ 0 ][ 0 ] = 1 - p[ a[ 0 ] - 'a' ];
}

void work( )
{
    int i, j, k, i2, t;
    double q;
    sum = 0;
    for ( i = 1; i < m; i++ )
    {
        for ( k = -1; k < l - 1; k++ )
        {
            for ( i2 = 0; i2 < 26; i2++ )
            {
                t = k;
                while ( t >= 0 && a[ t + 1 ] != i2 + 'a' ) t = next[ t ];
                if ( a[ t + 1 ] == i2 + 'a' ) t++;
                f[ i ][ t + 1 ] += f[ i - 1 ][ k + 1 ] * p[ i2 ];
            }
        }
        f[ i ][ l ] += f[ i - 1 ][ l ];
    }
    printf("%.2lf%%\n", f[ m - 1 ][ l ] * 100 );
}

int main( )
{
    while ( scanf("%d%d", &n, &m) != EOF )
    {
        if ( !n && !m ) break;
        init( );
        work( );
    }
    return 0;
}
